<?php
require_once 'function.php';

//利用XPath和DOM的方式尋找網頁中的特定字元

function XPath($id) {
    $report=array();
    $pathcodes=PathCodes($id);
    $url='http://172.16.38.1/DigReport/Lab/PathReport.asp?PathCode='.$pathcodes[0].'&ChartNo='.$id;
    $dom=ntuhDom($url);
    $xpath=new DOMXPath($dom);
    foreach ($xpath->query('//td[.="器官"]') as $td){
        $report['organ'][]=trim($td->nextSibling->nextSibling->nodeValue);
    }
    return $report;
}

$id='2569455';  //2569455 tongue cancer 有數次pathology report  

$path=XPath($id);

echo "<pre>";
var_dump ($path);
echo "</pre>";

?>
